<?php
class Cp extends MY_Controller {

       function __construct()
       {
            parent::__construct();
       }

	   function index(){
			$this->load->model('cp_model');
			if($this->cp_model->update_admin_info($_SESSION['admin_info']['id'])!=0){//更新管理员信息（最后登录时间、IP）
				$error['detail']="管理员信息更新失败，请与技术支持联系！";
				$error['min']=3;
				$error['url']=base_url()."manage/login";
			$this->load->view('manage/errormsg_view',$error);
			}else{
				$data['title']='好医生导医网后台管理中心('.$_SESSION['admin_info']['area'].'站)';
				$data['baseurl']=base_url();
				$this->load->view('manage/admin_index_view',$data);
				}
		}
		
		//左侧菜单框架页
		function left(){
			$data['user_type']=$_SESSION['admin_info']['user_type'];//读取管理员类型(0：高级，1：普通)
			$data['baseurl']=base_url();
			$this->load->view('manage/cp_left_view',$data);
		}

		//顶部框架页
		function top(){
			$data['user_name']=$_SESSION['admin_info']['user_name'];//读取管理员用户名
			$data['user_truename']=$_SESSION['admin_info']['user_truename'];//读取管理员姓名
			if($_SESSION['admin_info']['user_lasttime']!="") {//读取管理员上次登陆时间
					$data['user_lasttime']=date('m-d H:i',$_SESSION['admin_info']['user_lasttime']);
				}else{
					$data['user_lasttime']=date('m-d H:i');
					}
			$data['baseurl']=base_url();
			$this->load->view('manage/cp_top_view',$data);
		}
		
		//右侧框架页
		function right(){
			$data['user_name']=$_SESSION['admin_info']['user_name'];//读取管理员用户名
			$data['user_truename']=$_SESSION['admin_info']['user_truename'];//读取管理员姓名
			if($_SESSION['admin_info']['user_lasttime']!="") {//读取管理员上次登陆时间
					$data['user_lasttime']=date('m-d H:i',$_SESSION['admin_info']['user_lasttime']);
				}else{
					$data['user_lasttime']=date('m-d H:i');
					}
			$data['baseurl']=base_url();
			$this->load->view('manage/cp_right_view',$data);
		}
		

		//退出系统
		function out(){
			if(!isset($_SESSION)){//判断是否开启session
				session_start();
			}
			if (isset($_SESSION['admin_info'])){  
				unset($_SESSION['admin_info']);  
				session_destroy();//销毁session
			}
			$msg['detail']="您已成功退出网站后台管理中心！";
			$msg['min']=3;
			$msg['url']=base_url()."manage/login";
			$this->load->view('manage/message_view',$msg);
		}

}
?>
